# -*- utf-8 -*-
# author : li shi jie
# Email : yr785339493@qq.com
import pymysql

class Mysql:
    # 开启连接#
    def __init__(self, coon, cursor):
        self.coon = coon
        self.cursor = cursor
    # 插入
    def insert_to_mysql(self, data=None):
        sql='''
        insert into wx_info(wx_nickname,wx_logurl,wx_qrcode,wx_num,wx_item,tag,expect_fans,mean_read,likes,message,documents_nums)
        values (%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s)
        '''
        data = (data["wx_nickname"],data["wx_logurl"],data["wx_qrcode"],data["wx_num"],data["wx_item"],data["tag"],data["expect_fans"],data["mean_read"],data["likes"],data["message"],data["documents_nums"])
        return sql, data
    def close_mysql(self):
       # 关闭查询
        self.cursor.close()
        self.coon.close()

if __name__ == '__main__':
    coon = pymysql.connect('127.0.0.1', 'root', '123456', 'weixin', charset='utf8')
    cursor = coon.cursor()
    db = Mysql(coon, cursor)
